<?php

namespace app\store\controller;

use app\models\{StoreUser};
use think\Db;
use think\facade\Debug;
use think\Facade\Config as Configs;
use app\facade\Redis;


class Main extends Base
{

    public function welcome()
    {
        if ($this->request->isAjax()) {
            $model = new StoreUser();
            $post = input();
            $page = input('page/d') ?? 1;
            $limit = input('limit/d') ?? 10;
            $where = array();
            if (!empty($post['title'])) {
                $where[] = ['mobile', 'like', '%' . $post['title'] . '%'];
            }
            $where[] = ['storeid', '=', $this->request->store['id']];
            $count = $model->where($where)->count();
            // $page = ($count <= $limit) ? 1 : $page;
            $list = $model->where($where)->order("id desc")->limit($limit)->page($page)->select();
            return json(['code' => 200, 'msg' => '获取成功', 'data' => $list, 'count' => $count]);
        } else {
            return view(null, []);
        }
    }

    public function index()
    {
        $store = $this->request->store;
        return view(null, [
            'store' => $store
        ]);
    }


    public function miss()
    {
        return view('404');
    }

    public function miss2()
    {
        return view('500');
    }
}
